package com.caocaog.market.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecg.common.system.base.entity.groups.UpdateGroup;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

/**
 * 协议管理
 *
 * @author chechen
 * @date 2021-12-28
 */
@Data
@TableName("mk_protocol_basic")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "mk_protocol_basic对象", description = "协议管理")
public class Protocol implements Serializable {
    private static final long serialVersionUID = 1L;

    @TableId(type = IdType.INPUT)
    @NotBlank(message = "更新时，id不能为空", groups = {UpdateGroup.class})
    @ApiModelProperty(value = "ID")
    private Integer id;

    @ApiModelProperty(value = "创建人")
    private String createBy;

    @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @ApiModelProperty(value = "更新人")
    private String updateBy;

    @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "更新时间")
    private Date updateTime;

    @TableField(update = "%s+1")
    @ApiModelProperty(value = "版本号", hidden = true)
    private Integer lockVersion;

    @Dict(dicCode = "mk_whether")
    @TableLogic
    @ApiModelProperty(value = "是否删除", hidden = true)
    private Integer delFlag;

    @NotNull(message = "协议类型不能为空")
    @ApiModelProperty(value = "协议类型")
    private Integer type;

    @NotBlank(message = "协议标题不能为空")
    @ApiModelProperty(value = "协议标题")
    private String title;

    @NotBlank(message = "协议内容不能为空")
    @ApiModelProperty(value = "协议内容")
    private String content;

    public void clearFields () {
        this.delFlag = null;
        this.createBy = null;
        this.createTime = null;
        this.updateBy = null;
        this.updateTime = null;
    }

}
